<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>DOM对象</title>
</head>
<body>
<img id="light" src="../../img/off.gif"><br>
<div class="cls">
    传智教育
</div>
<div class="cls">
    黑马程序员
</div>
<input type="checkbox" name="hobby"/> video
<input type="checkbox" name="hobby"/> audio
<input type="checkbox" name="hobby"/> game

</body>
<script type="text/javascript">

    var elementById = document.getElementById("light");
    console.log(elementById);
    elementById.src = "../../img/on.gif";

    var divs = document.getElementsByTagName("div");
    /*
     * 	style:	设置样式
     * 	innerHTML:	设置内容
     *  innerText:  设置文本内容
     * */
    for (let i = 0; i < divs.length; i++) {
        divs[i].style.color="red";
        console.log(divs[i]);
        divs[i].innerHTML='<h3>黑马</h3>';
    }


    var hobbys = document.getElementsByName("hobby");
    for (let i = 0; i < hobbys.length; i++) {
        console.log("hobbys:" + hobbys[i]);
        hobbys[i].checked="checked";

    }

    var cls = document.getElementsByClassName("cls");
    for (let i = 0; i < cls.length; i++) {
        console.log("cls:" + cls[i]);
    }

</script>
</html>